import { getService, getShop, addService, updateService, delService, updateShopDoorservice } from '@/api/service';

export default {
    namespaced: true,
    state: {
        serviceList: {},
        shopList: {}
    },
    getters: {
        getServiceList(state) {
            return state.serviceList
        },
        getShopList(state) {
            return state.shopList
        }
    },
    mutations: {
        getServiceMutation(state, payload) {
            state.serviceList = payload;
        },
        getShopMutation(state, payload) {
            state.shopList = payload;
        },
        // ///不要删！！！！！！！！！！
        //不要删！！！！！！
        updateShopDoorserviceMtt(state, payload) {
            state.shopDoorstate = payload
        },
    },
    actions: {
        getServiceAction({commit},payload) {
            getService().then(( res ) => {
                commit('getServiceMutation', res)
            })
        },
        getShopAction({ commit }, payload) {
            getShop().then((res) => {
                commit('getShopMutation', res)
            })
        },
        addServiceAction({ commit }, payload) {
            addService(payload)
        },
        updateServiceAction({ commit }, payload) {
            let result = JSON.stringify(payload)
            updateService(JSON.parse(result))
        },
        delServiceAction({commit},payload) {
            delService(payload)
        },

        // ///不要删！！！！！！！！！！
        //不要删！！！！！！
        updateShopDoorserviceAction(context, payload) {
            updateShopDoorservice(payload)
        },
    }
}